1 Effect of UPSTM-Based Decorrelation on Feature Discovery

1.0.1 Loading the libraries

library("FRESA.CAD")
library(readxl)
library(igraph)
library(umap)
library(tsne)
library(entropy)
library(mlbench)
library(psych)
library(whitening)
library("vioplot")
library("rpart")

op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('table.split.table', 400)
pander::panderOptions('keep.trailing.zeros',TRUE)

1.1 Material and Methods

mlBench library

Newman, D.J. & Hettich, S. & Blake, C.L. & Merz, C.J. (1998). UCI Repository of machine learning databases [http://www.ics.uci.edu/~mlearn/MLRepository.html]. Irvine, CA: University of California, Department of Information and Computer Science.

1.2 The Data

#data(PimaIndiansDiabetes)
#pander::pander(table(PimaIndiansDiabetes$diabetes))
#PimaIndiansDiabetes$diabetes <- 1*(PimaIndiansDiabetes$diabetes=="pos")

data("PimaIndiansDiabetes2", package = "mlbench")
PimaIndiansDiabetes  <- PimaIndiansDiabetes2[complete.cases(PimaIndiansDiabetes2),]


#data(PimaIndiansDiabetes)
#PimaIndiansDiabetes  <- PimaIndiansDiabetes[complete.cases(PimaIndiansDiabetes),]


PimaIndiansDiabetes_mat <- as.data.frame(model.matrix(diabetes~.*.*.,PimaIndiansDiabetes)[,-1])
fnames <- colnames(PimaIndiansDiabetes_mat)
fnames <- str_replace_all(fnames," ","_")
fnames <- str_replace_all(fnames,"/","_")
fnames <- str_replace_all(fnames,":","_x_")
colnames(PimaIndiansDiabetes_mat) <- fnames

pander::pander(table(PimaIndiansDiabetes$diabetes))
neg pos
262 130
PimaIndiansDiabetes_mat$diabetes <- 1*(PimaIndiansDiabetes$diabetes=="pos")

1.2.0.1 Standarize the names for the reporting

studyName <- "Diabetes"
dataframe <- PimaIndiansDiabetes_mat
outcome <- "diabetes"

thro <- 0.8
TopVariables <- 3
cexheat = 0.45

1.3 Generaring the report

1.3.1 Libraries

Some libraries

library(psych)
library(whitening)
library("vioplot")
library("rpart")

1.3.2 Data specs

pander::pander(c(rows=nrow(dataframe),col=ncol(dataframe)-1))
rows col
392 92
pander::pander(table(dataframe[,outcome]))
0 1
262 130

varlist <- colnames(dataframe)
varlist <- varlist[varlist != outcome]

largeSet <- length(varlist) > 1500 

1.3.3 Scaling the data

Scaling and removing near zero variance columns and highly co-linear(r>0.99999) columns


  ### Some global cleaning
  sdiszero <- apply(dataframe,2,sd) > 1.0e-16
  dataframe <- dataframe[,sdiszero]

  varlist <- colnames(dataframe)[colnames(dataframe) != outcome]
  tokeep <- c(as.character(correlated_Remove(dataframe,varlist,thr=0.99999)),outcome)
  dataframe <- dataframe[,tokeep]

  varlist <- colnames(dataframe)
  varlist <- varlist[varlist != outcome]
  
  iscontinous <- sapply(apply(dataframe,2,unique),length) >= 5 ## Only variables with enough samples



dataframeScaled <- FRESAScale(dataframe,method="OrderLogit")$scaledData

1.4 The heatmap of the data

numsub <- nrow(dataframe)
if (numsub > 1000) numsub <- 1000


if (!largeSet)
{

  hm <- heatMaps(data=dataframeScaled[1:numsub,],
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 xlab="Feature",
                 ylab="Sample",
                 srtCol=45,
                 srtRow=45,
                 cexCol=cexheat,
                 cexRow=cexheat
                 )
  par(op)
}

1.4.0.1 Correlation Matrix of the Data

The heat map of the data


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  #cormat <- Rfast::cora(as.matrix(dataframe[,varlist]),large=TRUE)
  cormat <- cor(dataframe[,varlist],method="pearson")
  cormat[is.na(cormat)] <- 0
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
  #                  scale = "row",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Original Correlation",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="|Pearson Correlation|",
                    xlab="Feature", ylab="Feature")
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.9860671

1.5 The decorrelation


DEdataframe <- IDeA(dataframe,verbose=TRUE,thr=thro)
#> 
#>  pregnant_x_pressure_x_age pregnant_x_pressure_x_insulin pregnant_x_pressure_x_pedigree insulin_x_mass_x_pedigree glucose_x_triceps_x_insulin pressure_x_insulin_x_age 
#>   pregnant    glucose   pressure    triceps    insulin       mass 
#> 0.83695652 0.03260870 0.01086957 0.13043478 0.54347826 0.04347826 
#> 
#>  Included: 92 , Uni p: 0.001630435 , Base Size: 11 , Rcrit: 0.1482456 
#> 
#> 
 1 <R=0.986,thr=0.950>, Top: 15< 3 >[Fa= 15 ]( 15 , 39 , 0 ),<|><>Tot Used: 54 , Added: 39 , Zero Std: 0 , Max Cor: 0.965
#> 
 2 <R=0.965,thr=0.950>, Top: 2< 2 >[Fa= 17 ]( 2 , 4 , 15 ),<|><>Tot Used: 57 , Added: 4 , Zero Std: 0 , Max Cor: 0.950
#> 
 3 <R=0.950,thr=0.950>, Top: 1< 1 >[Fa= 18 ]( 1 , 1 , 17 ),<|><>Tot Used: 57 , Added: 1 , Zero Std: 0 , Max Cor: 0.949
#> 
 4 <R=0.949,thr=0.900>, Top: 22< 2 >[Fa= 29 ]( 22 , 32 , 18 ),<|><>Tot Used: 83 , Added: 32 , Zero Std: 0 , Max Cor: 0.949
#> 
 5 <R=0.949,thr=0.900>, Top: 5< 1 >[Fa= 34 ]( 5 , 5 , 29 ),<|><>Tot Used: 84 , Added: 5 , Zero Std: 0 , Max Cor: 0.900
#> 
 6 <R=0.900,thr=0.800>, Top: 20< 1 >[Fa= 40 ]( 16 , 24 , 34 ),<|><>Tot Used: 87 , Added: 24 , Zero Std: 0 , Max Cor: 0.858
#> 
 7 <R=0.858,thr=0.800>, Top: 2< 1 >[Fa= 41 ]( 2 , 2 , 40 ),<|><>Tot Used: 89 , Added: 2 , Zero Std: 0 , Max Cor: 0.851
#> 
 8 <R=0.851,thr=0.800>, Top: 2< 1 >[Fa= 41 ]( 1 , 1 , 41 ),<|><>Tot Used: 89 , Added: 1 , Zero Std: 0 , Max Cor: 0.797
#> 
 9 <R=0.797,thr=0.800>
#> 
 [ 9 ], 0.7969239 Decor Dimension: 89 Nused: 89 . Cor to Base: 62 , ABase: 92 , Outcome Base: 0 
#> 
varlistc <- colnames(DEdataframe)[colnames(DEdataframe) != outcome]

pander::pander(sum(apply(dataframe[,varlist],2,var)))

4.99e+12

pander::pander(sum(apply(DEdataframe[,varlistc],2,var)))

1.05e+12

pander::pander(entropy(discretize(unlist(dataframe[,varlist]), 256)))

1.13

pander::pander(entropy(discretize(unlist(DEdataframe[,varlistc]), 256)))

0.918

1.5.1 The decorrelation matrix


if (!largeSet)
{

  par(cex=0.6,cex.main=0.85,cex.axis=0.7)
  
  UPLTM <- attr(DEdataframe,"UPLTM")
  
  gplots::heatmap.2(1.0*(abs(UPLTM)>0),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Decorrelation matrix",
                    cexRow = cexheat,
                    cexCol = cexheat,
                   srtCol=45,
                   srtRow=45,
                    key.title=NA,
                    key.xlab="|Beta|>0",
                    xlab="Output Feature", ylab="Input Feature")
  
  par(op)
  
  
  
}

1.5.2 Formulas Network

Displaying the features associations

par(op)

if ((ncol(dataframe) < 1000) && (ncol(dataframe)>10))
{

  DEdataframeB <- ILAA(dataframe,verbose=TRUE,thr=thro,bootstrap=30)

  transform <- 1*(attr(DEdataframeB,"UPLTM") != 0)
  print(ncol(transform))
  thrcol <- 1 + 0.025*nrow(transform)
  rsum <- apply(1*(transform !=0),1,sum) > 2
  csum <- apply(1*(transform !=0),2,sum) > thrcol | rsum
  transform <- transform[csum,csum]
  csum <- (apply(1*(transform !=0),2,sum) > 1) & (apply(1*(transform !=0),1,sum) > 1)
  transform <- transform[csum,csum]
  print(ncol(transform))
  if (ncol(transform)>100)
  {
    thrcol <- 1 + 0.10*nrow(transform)
    rsum <- apply(1*(transform !=0),1,sum) > 4
    csum <- apply(1*(transform !=0),2,sum) > thrcol | rsum
    transform <- transform[csum,csum]
    csum <- (apply(1*(transform !=0),2,sum) > 3) & (apply(1*(transform !=0),1,sum) > 3)
    transform <- transform[csum,csum]
  }
  print(ncol(transform))
  if (ncol(transform)>100)
  {
    thrcol <- 1 + 0.20*nrow(transform)
    rsum <- apply(1*(transform !=0),1,sum) > 8
    csum <- apply(1*(transform !=0),2,sum) > thrcol | rsum
    transform <- transform[csum,csum]
    csum <- (apply(1*(transform !=0),2,sum) > 7) & (apply(1*(transform !=0),1,sum) > 7)
    transform <- transform[csum,csum]
  }
  print(ncol(transform))

  if ((ncol(transform) > 10) && (ncol(transform) < 150))
  {
    
      gplots::heatmap.2(transform,
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Red Decorrelation matrix",
                    cexRow = cexheat,
                    cexCol = cexheat,
                   srtCol=45,
                   srtRow=45,
                    key.title=NA,
                    key.xlab="|Beta|>0",
                    xlab="Output Feature", ylab="Input Feature")
  
      par(op)

    
    colnames(transform) <- str_remove_all(colnames(transform),"La_")
    
    VertexSize <- apply(transform,2,mean)
    VertexSize <- 5*VertexSize/max(VertexSize)
    
    gr <- graph_from_adjacency_matrix(transform,mode = "directed",diag = FALSE,weighted=TRUE)
    gr$layout <- layout_with_fr
    
    fc <- cluster_optimal(gr)
    plot(fc, gr,
         edge.width = 0.5*E(gr)$weight,
         vertex.size=VertexSize,
         edge.arrow.size=0.5,
         edge.arrow.width=0.5,
         vertex.label.cex=0.65,
         vertex.label.dist=1,
         main="Feature Association")
  }
}
#> fast | LM |
#>  pregnant_x_pressure_x_age pregnant_x_pressure_x_insulin pregnant_x_pressure_x_pedigree insulin_x_mass_x_pedigree glucose_x_triceps_x_insulin pressure_x_insulin_x_age 
#>   pregnant    glucose   pressure    triceps    insulin       mass 
#> 0.83695652 0.03260870 0.01086957 0.13043478 0.54347826 0.04347826 
#> 
#>  Included: 92 , Uni p: 0.001630435 , Base Size: 11 , Rcrit: 0.1482456 
#> 
#> 
 1 <R=0.986,thr=0.950>, Top: 15< 3 >[Fa= 15 ]( 15 , 39 , 0 ),<|><>Tot Used: 54 , Added: 39 , Zero Std: 0 , Max Cor: 0.965
#> 
 2 <R=0.965,thr=0.950>, Top: 2< 2 >[Fa= 17 ]( 2 , 4 , 15 ),<|><>Tot Used: 57 , Added: 4 , Zero Std: 0 , Max Cor: 0.950
#> 
 3 <R=0.950,thr=0.950>, Top: 1< 1 >[Fa= 18 ]( 1 , 1 , 17 ),<|><>Tot Used: 57 , Added: 1 , Zero Std: 0 , Max Cor: 0.949
#> 
 4 <R=0.949,thr=0.900>, Top: 22< 2 >[Fa= 29 ]( 22 , 32 , 18 ),<|><>Tot Used: 83 , Added: 32 , Zero Std: 0 , Max Cor: 0.949
#> 
 5 <R=0.949,thr=0.900>, Top: 5< 1 >[Fa= 34 ]( 5 , 5 , 29 ),<|><>Tot Used: 84 , Added: 5 , Zero Std: 0 , Max Cor: 0.900
#> 
 6 <R=0.900,thr=0.800>, Top: 20< 1 >[Fa= 40 ]( 16 , 24 , 34 ),<|><>Tot Used: 87 , Added: 24 , Zero Std: 0 , Max Cor: 0.858
#> 
 7 <R=0.858,thr=0.800>, Top: 2< 1 >[Fa= 41 ]( 2 , 2 , 40 ),<|><>Tot Used: 89 , Added: 2 , Zero Std: 0 , Max Cor: 0.851
#> 
 8 <R=0.851,thr=0.800>, Top: 2< 1 >[Fa= 41 ]( 1 , 1 , 41 ),<|><>Tot Used: 89 , Added: 1 , Zero Std: 0 , Max Cor: 0.797
#> 
 9 <R=0.797,thr=0.800>
#> 
 [ 9 ], 0.7969239 Decor Dimension: 89 Nused: 89 . Cor to Base: 62 , ABase: 92 , Outcome Base: 0 
#> 
bootstrapping->..............................
#> 
[1] 89
#> [1] 71
#> [1] 71
#> [1] 71


par(op)

1.6 The heatmap of the decorrelated data

if (!largeSet)
{

  hm <- heatMaps(data=DEdataframe[1:numsub,],
                 Outcome=outcome,
                 Scale=TRUE,
                 hCluster = "row",
                 cexRow = cexheat,
                 cexCol = cexheat,
                 srtCol=45,
                 srtRow=45,
                 xlab="Feature",
                 ylab="Sample")
  par(op)
}

1.7 The correlation matrix after decorrelation

if (!largeSet)
{

  cormat <- cor(DEdataframe[,varlistc],method="pearson")
  cormat[is.na(cormat)] <- 0
  
  gplots::heatmap.2(abs(cormat),
                    trace = "none",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "Correlation after ILAA",
                    cexRow = cexheat,
                    cexCol = cexheat,
                     srtCol=45,
                     srtRow=45,
                    key.title=NA,
                    key.xlab="|Pearson Correlation|",
                    xlab="Feature", ylab="Feature")
  
  par(op)
  diag(cormat) <- 0
  print(max(abs(cormat)))
}

[1] 0.7969239

1.8 U-MAP Visualization of features

1.8.1 The UMAP based on LASSO on Raw Data


if (nrow(dataframe) < 1000)
{
  classes <- unique(dataframe[1:numsub,outcome])
  raincolors <- rainbow(length(classes))
  names(raincolors) <- classes
  datasetframe.umap = umap(scale(dataframe[1:numsub,varlist]),n_components=2)
  plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: Original",t='n')
  text(datasetframe.umap$layout,labels=dataframe[1:numsub,outcome],col=raincolors[dataframe[1:numsub,outcome]+1])
}

1.8.2 The decorralted UMAP

if (nrow(dataframe) < 1000)
{

  datasetframe.umap = umap(scale(DEdataframe[1:numsub,varlistc]),n_components=2)
  plot(datasetframe.umap$layout,xlab="U1",ylab="U2",main="UMAP: After ILAA",t='n')
  text(datasetframe.umap$layout,labels=DEdataframe[1:numsub,outcome],col=raincolors[DEdataframe[1:numsub,outcome]+1])
}

1.9 Univariate Analysis

1.9.1 Univariate



univarRAW <- uniRankVar(varlist,
               paste(outcome,"~1"),
               outcome,
               dataframe,
               rankingTest="AUC")



univarDe <- uniRankVar(varlistc,
               paste(outcome,"~1"),
               outcome,
               DEdataframe,
               rankingTest="AUC",
               )

1.9.2 Final Table


univariate_columns <- c("caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC")

##top variables
topvar <- c(1:length(varlist)) <= TopVariables
tableRaw <- univarRAW$orderframe[topvar,univariate_columns]
pander::pander(tableRaw)
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
glucose_x_mass_x_age 186646 75784 102786 53357 8.45e-05 0.845
glucose_x_age 5278 2104 3206 1444 9.98e-07 0.825
glucose_x_mass 5189 1429 3563 1209 1.02e-01 0.821


topLAvar <- univarDe$orderframe$Name[str_detect(univarDe$orderframe$Name,"La_")]
topLAvar <- unique(c(univarDe$orderframe$Name[topvar],topLAvar[1:as.integer(TopVariables/2)]))
finalTable <- univarDe$orderframe[topLAvar,univariate_columns]


pander::pander(finalTable)
  caseMean caseStd controlMean controlStd controlKSP ROCAUC
glucose_x_pressure_x_age 397284 184042.7 225271 119951.9 2.10e-04 0.809
glucose 145 29.8 111 24.6 3.43e-02 0.806
glucose_x_triceps_x_insulin 1054818 904289.8 465722 612619.7 6.61e-13 0.787
La_insulin_x_mass_x_age 31742 29242.4 15567 22041.9 3.18e-09 0.713

dc <- getLatentCoefficients(DEdataframe)
fscores <- attr(DEdataframe,"fscore")


pander::pander(c(mean=mean(sapply(dc,length)),total=length(dc),fraction=length(dc)/(ncol(dataframe)-1)))
mean total fraction
2.82 76 0.826

theCharformulas <- attr(dc,"LatentCharFormulas")


finalTable <- rbind(finalTable,tableRaw[topvar[!(topvar %in% topLAvar)],univariate_columns])


orgnamez <- rownames(finalTable)
orgnamez <- str_remove_all(orgnamez,"La_")
finalTable$RAWAUC <- univarRAW$orderframe[orgnamez,"ROCAUC"]
finalTable$DecorFormula <- theCharformulas[rownames(finalTable)]
finalTable$fscores <- fscores[rownames(finalTable)]

Final_Columns <- c("DecorFormula","caseMean","caseStd","controlMean","controlStd","controlKSP","ROCAUC","RAWAUC","fscores")

finalTable <- finalTable[order(-finalTable$ROCAUC),]
pander::pander(finalTable[,Final_Columns])
  DecorFormula caseMean caseStd controlMean controlStd controlKSP ROCAUC RAWAUC fscores
glucose_x_mass_x_age NA 186646 75783.6 102786 53357.3 8.45e-05 0.845 0.845 NA
glucose_x_age NA 5278 2103.8 3206 1444.5 9.98e-07 0.825 0.825 NA
glucose_x_mass NA 5189 1429.4 3563 1208.6 1.02e-01 0.821 0.821 NA
glucose_x_pressure_x_age NA 397284 184042.7 225271 119951.9 2.10e-04 0.809 0.809 4
glucose NA 145 29.8 111 24.6 3.43e-02 0.806 0.806 NA
glucose_x_triceps_x_insulin NA 1054818 904289.8 465722 612619.7 6.61e-13 0.787 0.787 5
La_insulin_x_mass_x_age + (0.106)glucose_x_pressure_x_insulin - (0.201)glucose_x_insulin_x_mass - (0.452)pressure_x_insulin_x_age + insulin_x_mass_x_age 31742 29242.4 15567 22041.9 3.18e-09 0.713 0.791 -2

1.10 Comparing ILAA vs PCA vs EFA

1.10.1 PCA

featuresnames <- colnames(dataframe)[colnames(dataframe) != outcome]
pc <- prcomp(dataframe[,iscontinous],center = TRUE,scale. = TRUE)   #principal components
predPCA <- predict(pc,dataframe[,iscontinous])
PCAdataframe <- as.data.frame(cbind(predPCA,dataframe[,!iscontinous]))
colnames(PCAdataframe) <- c(colnames(predPCA),colnames(dataframe)[!iscontinous]) 
#plot(PCAdataframe[,colnames(PCAdataframe)!=outcome],col=dataframe[,outcome],cex=0.65,cex.lab=0.5,cex.axis=0.75,cex.sub=0.5,cex.main=0.75)

#pander::pander(pc$rotation)


PCACor <- cor(PCAdataframe[,colnames(PCAdataframe) != outcome])


  gplots::heatmap.2(abs(PCACor),
                    trace = "none",
  #                  scale = "row",
                    mar = c(5,5),
                    col=rev(heat.colors(5)),
                    main = "PCA Correlation",
                    cexRow = 0.5,
                    cexCol = 0.5,
                     srtCol=45,
                     srtRow= -45,
                    key.title=NA,
                    key.xlab="Pearson Correlation",
                    xlab="Feature", ylab="Feature")

1.10.2 EFA


EFAdataframe <- dataframeScaled

if (length(iscontinous) < 2000)
{
  topred <- min(length(iscontinous),nrow(dataframeScaled),ncol(predPCA)/2)
  if (topred < 2) topred <- 2
  
  uls <- fa(dataframeScaled[,iscontinous],nfactors=topred,rotate="varimax",warnings=FALSE)  # EFA analysis
  predEFA <- predict(uls,dataframeScaled[,iscontinous])
  EFAdataframe <- as.data.frame(cbind(predEFA,dataframeScaled[,!iscontinous]))
  colnames(EFAdataframe) <- c(colnames(predEFA),colnames(dataframeScaled)[!iscontinous]) 


  
  EFACor <- cor(EFAdataframe[,colnames(EFAdataframe) != outcome])
  
  
    gplots::heatmap.2(abs(EFACor),
                      trace = "none",
    #                  scale = "row",
                      mar = c(5,5),
                      col=rev(heat.colors(5)),
                      main = "EFA Correlation",
                      cexRow = 0.5,
                      cexCol = 0.5,
                       srtCol=45,
                       srtRow= -45,
                      key.title=NA,
                      key.xlab="Pearson Correlation",
                      xlab="Feature", ylab="Feature")
}

1.11 Effect on CAR modeling

par(op)
par(xpd = TRUE)
dataframe[,outcome] <- factor(dataframe[,outcome])
rawmodel <- rpart(paste(outcome,"~."),dataframe,control=rpart.control(maxdepth=3))
pr <- predict(rawmodel,dataframe,type = "class")

  ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
  if (length(unique(pr))>1)
  {
    plot(rawmodel,main="Raw",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
    text(rawmodel, use.n = TRUE,cex=0.75)
    ptab <- epiR::epi.tests(table(pr==0,dataframe[,outcome]==0))
  }


pander::pander(table(dataframe[,outcome],pr))
  0 1
0 230 32
1 29 101
pander::pander(ptab$detail[c(5,3,4,6),])
  statistic est lower upper
5 diag.ac 0.844 0.805 0.879
3 se 0.777 0.696 0.845
4 sp 0.878 0.832 0.915
6 diag.or 25.032 14.380 43.574

par(op)
par(xpd = TRUE)
DEdataframe[,outcome] <- factor(DEdataframe[,outcome])
IDeAmodel <- rpart(paste(outcome,"~."),DEdataframe,control=rpart.control(maxdepth=3))
pr <- predict(IDeAmodel,DEdataframe,type = "class")

  ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
  if (length(unique(pr))>1)
  {
    plot(IDeAmodel,main="ILAA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
    text(IDeAmodel, use.n = TRUE,cex=0.75)
    ptab <- epiR::epi.tests(table(pr==0,DEdataframe[,outcome]==0))
  }

pander::pander(table(DEdataframe[,outcome],pr))
  0 1
0 223 39
1 32 98
pander::pander(ptab$detail[c(5,3,4,6),])
  statistic est lower upper
5 diag.ac 0.819 0.777 0.856
3 se 0.754 0.671 0.825
4 sp 0.851 0.802 0.892
6 diag.or 17.511 10.365 29.584

par(op)
par(xpd = TRUE)
PCAdataframe[,outcome] <- factor(PCAdataframe[,outcome])
PCAmodel <- rpart(paste(outcome,"~."),PCAdataframe,control=rpart.control(maxdepth=3))
pr <- predict(PCAmodel,PCAdataframe,type = "class")
ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
if (length(unique(pr))>1)
{
  plot(PCAmodel,main="PCA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
  text(PCAmodel, use.n = TRUE,cex=0.75)
  ptab <- epiR::epi.tests(table(pr==0,PCAdataframe[,outcome]==0))
}

pander::pander(table(PCAdataframe[,outcome],pr))
  0 1
0 236 26
1 43 87
pander::pander(ptab$detail[c(5,3,4,6),])
  statistic est lower upper
5 diag.ac 0.824 0.783 0.860
3 se 0.669 0.581 0.749
4 sp 0.901 0.858 0.934
6 diag.or 18.365 10.644 31.687


par(op)

1.11.1 EFA


  EFAdataframe[,outcome] <- factor(EFAdataframe[,outcome])
  EFAmodel <- rpart(paste(outcome,"~."),EFAdataframe,control=rpart.control(maxdepth=3))
  pr <- predict(EFAmodel,EFAdataframe,type = "class")
  
  ptab <- list(er="Error",detail=matrix(nrow=6,ncol=1))
  if (length(unique(pr))>1)
  {
    plot(EFAmodel,main="EFA",branch=0.5,uniform = TRUE,compress = TRUE,margin=0.1)
    text(EFAmodel, use.n = TRUE,cex=0.75)
    ptab <- epiR::epi.tests(table(pr==0,EFAdataframe[,outcome]==0))
  }


  pander::pander(table(EFAdataframe[,outcome],pr))
  0 1
0 223 39
1 39 91
  pander::pander(ptab$detail[c(5,3,4,6),])
  statistic est lower upper
5 diag.ac 0.801 0.758 0.839
3 se 0.700 0.613 0.777
4 sp 0.851 0.802 0.892
6 diag.or 13.342 8.041 22.138
  par(op)